<?php
class Common extends CI_Model {
	public function Update($table,$data,$insert=1,$id=array())
	{
		if($insert==1)
		{
			//$this->db->set($data);
			$this->db->insert($table,$data);
		}
		else
		{
			$this->db->update($table,$data,$id);
		}
	}
	function GetById($table,$data,$offset=0,$limit=0)
	{
		if($limit==0)
			$query = $this->db->get_where($table, $data);
		else
			$query = $this->db->get_where($table, $data,$limit,$offset);
		return $query->result();
	}
	function Get($table,$data=null,$offset=0,$limit=0)
	{
		if($limit==0)
			$query = $this->db->get_where($table, $data);
		else
			$query = $this->db->get_where($table, $data,$limit,$offset);
		return $query->result();
	}
	
	function Delete($table,$data)
	{
		//print_r($data);
		$this->db->delete($table, $data); 
	}
}
?>